<!--- <cfsilent> ---><!--- attributes.view - defines which display mode to show: day, week, weeklist, month, condensed --->
<!--- attributes.calendarLinkPage - the page that the user is taken to when they click an event --->
<cfparam name="Attributes.calendarLinkPage" type="string" default="" />
<!--- attributes.ExcludeTimeHeader - boolean to specifiy if the header on the calendar for times is displayed --->
<cfparam name="Attributes.ExcludeTimeHeader" type="boolean" default="no" />
<!--- attributes.KalendarRequest  contains the request based data and rules for Kalendar. --->
<cfparam name="Attributes.KalendarRequest" type="any" />
<!--- attributes.urlAddString - a URL string to add to the calendarLinkPage attribute --->
<cfparam name="Attributes.urlAddString" type="string" default="" />
<!--- attributes.view - defines which display mode to show: day, week, weeklist, month, condensed --->
<cfparam name="Attributes.view" type="string" default="list" />
<!--- attributes.ToolTipFormatter - utility object that contains methods to format tooltips --->
<cfparam name="Attributes.ToolTipFormatter" type="any" />

<cfscript>
	EventRecords = attributes.KalendarRequest.getReturnedEvents(session.user,request.timezones);
	KalendarConfig = attributes.KalendarRequest.getKalendarConfig();
	optionBarVars = structNew();
	optionBarVars.view = attributes.view;
	optionBarVars.KalendarRequest = attributes.KalendarRequest;
</cfscript>

<cfmodule template="OptionBar.cfm" attributecollection="#optionBarVars#">

<table class="calendarTable listTable">
	<cfoutput>
		<tr>
			<td class="listtimes">All Day Events</td>
			<td class="listday"><cfset isdata = 0 />
					<cfloop index="i" from="1" to="#ArrayLen(eventRecords)#">
					<cfif eventRecords[i].IsAllDayEvent>
						<cfsilent>
							<cfset isdata = isdata + 1 />
							<cfset variables.tooltipHeader = DateFormat(attributes.KalendarRequest.getLinkDate(),  "mmmm, d") />
							<cfif TimeFormat(eventRecords[i].StartDate,"h:mm tt") NEQ "12:00 AM">
								<cfset variables.tooltipHeader = variables.tooltipHeader & "&nbsp;&nbsp;&nbsp;" & TimeFormat(eventRecords[i].StartDate, 'h:mm tt') />
							</cfif>
							<cfset variables.tooltipHeader = variables.tooltipHeader & " - " & Left(Trim(eventRecords[i].Title), KalendarConfig.getToolTipSubLength()) />
							<cfif len(eventRecords[i].Teaser)>
								<cfset variables.tooltipBody = Left(eventRecords[i].Teaser, KalendarConfig.getMaxDescriptionSize()) />
								<cfif Len(eventRecords[i].Teaser) gt KalendarConfig.getMaxDescriptionSize()>
									<cfset variables.tooltipBody = variables.tooltipBody & " ..." />
								</cfif>
							<cfelse>
								<cfset variables.tooltipBody = Left(eventRecords[i].Description, KalendarConfig.getMaxDescriptionSize()) />
								<cfif Len(eventRecords[i].Description) gt KalendarConfig.getMaxDescriptionSize()>
									<cfset variables.tooltipBody = variables.tooltipBody & " ..." />
								</cfif>
							</cfif>
						</cfsilent>
						<!--- <div <cfif len(eventRecords[i].Teaser) OR len(eventRecords[i].Description)>title="header=[#variables.tooltipHeader#] body=[#variables.tooltipBody#] cssbody=[calendarTooltipSub] cssheader=[calendarTooltip]"</cfif> class="weeklisteventdisplay"<cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryBGColor))> style="background-color: ###eventRecords[i].CategoryBGColor#;"</cfif>><a href="#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(attributes.KalendarRequest.getLinkDate())#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>" class="weeklistlink"<cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryTextColor))> style="color: ###eventRecords[i].CategoryTextColor#;"</cfif>>#Trim(eventRecords[i].Title)#</a></div> --->
						<div class="eventDisplay"<cfif len(trim(eventRecords[i].Teaser)) OR len(trim(eventRecords[i].Description))> title="#Attributes.ToolTipFormatter.eventTitleTip(eventRecords[i].StartDate, eventRecords[i].EndDate, Trim(eventRecords[i].Title), KalendarConfig.getToolTipSubLength())#|#Attributes.ToolTipFormatter.eventBodyTip(eventRecords[i].Teaser, eventRecords[i].Description, KalendarConfig.getMaxDescriptionSize())#"</cfif><cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryBGColor))> style="background-color: ###eventRecords[i].CategoryBGColor#;"</cfif>>
							<a title="#trim(eventRecords[i].Title)#" href="#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(attributes.KalendarRequest.getLinkDate())#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>&KeepThis=true&TB_iframe=true&height=400&width=450" class="thickbox"<cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryTextColor))> style="color: ###eventRecords[i].CategoryTextColor#;"</cfif>>#trim(eventRecords[i].Title)#</a>
						</div>
						<!--- microformat --->
						<div style="display:none;" class="vevent">
							<span class="dtstamp">#DateFormat(Now(), "yyyy-mm-dd")#T#TimeFormat(Now(), "HH:mm:ss")#</span>
							<span class="summary title">#Trim(eventRecords[i].Title)#</span>
							<a href="#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(attributes.KalendarRequest.getLinkDate())#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>" class="url">Event Link</a>
							<div class="description">#eventRecords[i].Description#</div>
							<span class="dtstart" title="#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#T#TimeFormat(eventRecords[i].StartDate, "HH:mm:ss")#">#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#T#TimeFormat(eventRecords[i].StartDate, "HH:mm:ss")#</span>
							<cfif eventRecords[i].StartDate neq eventRecords[i].EndDate><span class="dtend" title="<cfif eventRecords[i].EndDate neq eventRecords[i].StartDate>#DateFormat(eventRecords[i].EndDate, "yyyy-mm-dd")#<cfelse>#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#</cfif>T#TimeFormat(eventRecords[i].EndDate, "HH:mm:ss")#"><cfif eventRecords[i].EndDate neq eventRecords[i].StartDate>#DateFormat(eventRecords[i].EndDate, "yyyy-mm-dd")#<cfelse>#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#</cfif>T#TimeFormat(eventRecords[i].EndDate, "HH:mm:ss")#</span></cfif>
						</div>
						
					</cfif>
				</cfloop>
				<cfif NOT isdata>&nbsp;</cfif>
			</td>
		</tr>
	</cfoutput>
	<cfset isdata = 0 />
	<cfloop from="0" to="23" index="k">
		<cfoutput>
			<tr>
				<td class="listtimes">#TimeFormat(DateAdd("h", k, "12:00 AM"), "h:mm tt")#</td>
				<td class="listdescription">
					<cfloop index="i" from="1" to="#ArrayLen(eventRecords)#">
						<cfif TimeFormat(eventRecords[i].StartDate) gte DateAdd("h", k, "12:00:00 AM") AND TimeFOrmat(eventRecords[i].StartDate) lte DateAdd("n", 59, DateAdd("h", k, "12:00:00 AM")) AND NOT eventRecords[i].isAllDayEvent>
							<cfsilent>
								<cfset isdata = isdata + 1 />
								<cfset variables.tooltipHeader = DateFormat(attributes.KalendarRequest.getLinkDate(),  "mmmm, d") />
								<cfif len(trim(eventRecords[i].StartDate))>
									<cfset variables.tooltipHeader = variables.tooltipHeader & "&nbsp;&nbsp;&nbsp;" & TimeFormat(eventRecords[i].StartDate, 'h:mm tt') />
								</cfif>
								<cfif eventRecords[i].StartDate neq eventRecords[i].EndDate>
									<cfset variables.tooltipHeader = variables.tooltipHeader & "&nbsp;&nbsp;-&nbsp;&nbsp;" & DateFormat(attributes.KalendarRequest.getLinkDate(),  "mmmm") & " " & DateFormat(eventRecords[i].EndDate, "d") />
								</cfif>
								<cfif TimeFormat(eventRecords[i].EndDate) NEQ  "12:00 AM">
									<cfset variables.tooltipHeader = variables.tooltipHeader & "&nbsp;&nbsp;&nbsp;" & TimeFormat(eventRecords[i].EndDate, 'h:mm tt') />
								</cfif>
								<cfset variables.tooltipHeader = variables.tooltipHeader & " - " & Left(Trim(eventRecords[i].Title), KalendarConfig.getToolTipSubLength()) />
								<cfif len(eventRecords[i].Teaser)>
									<cfset variables.tooltipBody = Left(eventRecords[i].Teaser, KalendarConfig.getMaxDescriptionSize()) />
									<cfif Len(eventRecords[i].Teaser) gt KalendarConfig.getMaxDescriptionSize()>
										<cfset variables.tooltipBody = variables.tooltipBody & " ..." />
									</cfif>
								<cfelse>
									<cfset variables.tooltipBody = Left(eventRecords[i].Description, KalendarConfig.getMaxDescriptionSize()) />
									<cfif Len(eventRecords[i].Description) gt KalendarConfig.getMaxDescriptionSize()>
										<cfset variables.tooltipBody = variables.tooltipBody & " ..." />
									</cfif>
								</cfif>
							</cfsilent>
							<!--- <div <cfif len(eventRecords[i].Teaser) OR len(eventRecords[i].Description)>title="header=[#variables.tooltipHeader#] body=[#variables.tooltipBody#] cssbody=[calendarTooltipSub] cssheader=[calendarTooltip]"</cfif> class="weeklisteventdisplay"<cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryBGColor))> style="background-color: ###eventRecords[i].CategoryBGColor#;"</cfif>><a href="#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(attributes.KalendarRequest.getLinkDate())#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>" class="weeklistlink"<cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryTextColor))> style="color: ###eventRecords[i].CategoryTextColor#;"</cfif>>#Trim(eventRecords[i].Title)#</a></div> --->
							<div style="display:none;" class="vevent">
								<span class="dtstamp">#DateFormat(Now(), "yyyy-mm-dd")#T#TimeFormat(Now(), "HH:mm:ss")#</span>
								<span class="summary title">#Trim(eventRecords[i].Title)#</span>
								<a href="#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(attributes.KalendarRequest.getLinkDate())#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>" class="url">Event Link</a>
								<div class="description">#eventRecords[i].Description#</div>
								<span class="dtstart" title="#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#T#TimeFormat(eventRecords[i].StartDate, "HH:mm:ss")#">#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#T#TimeFormat(eventRecords[i].StartDate, "HH:mm:ss")#</span>
								<cfif eventRecords[i].StartDate neq eventRecords[i].EndDate>
									<span class="dtend" title="<cfif eventRecords[i].EndDate neq eventRecords[i].StartDate>#DateFormat(eventRecords[i].EndDate, "yyyy-mm-dd")#<cfelse>#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#</cfif>T#TimeFormat(eventRecords[i].EndDate, "HH:mm:ss")#>">
										<cfif eventRecords[i].EndDate neq eventRecords[i].StartDate>
											#DateFormat(eventRecords[i].EndDate, "yyyy-mm-dd")#
										<cfelse>
											#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#
										</cfif>
										T#TimeFormat(eventRecords[i].EndDate, "HH:mm:ss")#
									</span>
								</cfif>
							</div>
							<div class="eventDisplay"<cfif len(trim(eventRecords[i].Teaser)) OR len(trim(eventRecords[i].Description))> title="#Attributes.ToolTipFormatter.eventTitleTip(eventRecords[i].StartDate, eventRecords[i].EndDate, Trim(eventRecords[i].Title), KalendarConfig.getToolTipSubLength())#|#Attributes.ToolTipFormatter.eventBodyTip(eventRecords[i].Teaser, eventRecords[i].Description, KalendarConfig.getMaxDescriptionSize())#"</cfif><cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryBGColor))> style="background-color: ###eventRecords[i].CategoryBGColor#;"</cfif>>
								<a title="#Trim(eventRecords[i].Title)#" href="#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(attributes.KalendarRequest.getLinkDate())#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>&KeepThis=true&TB_iframe=true&height=395&width=425" class="thickbox"<cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryTextColor))> style="color: ###eventRecords[i].CategoryTextColor#;"</cfif>>#Trim(eventRecords[i].Title)#</a>
							</div>
						</cfif>
					</cfloop>
					<cfif NOT isdata>&nbsp;</cfif>
					<cfset isdata = 0 />
				</td>
			</tr>
		</cfoutput>
	</cfloop>				
</table>